#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i)  
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;

const int N = 2e7+5;
char str[N],m[N];
int lens,lenm,z[N],p[N],l,r;
ll ans;

inline void Z(){
    z[1] = lenm , l = r = 0;
    rep(i,2,lenm){
        if(i <= r) z[i] = std::min(z[i-l+1],r-i+1);
        while(m[z[i]+1] == m[z[i]+i] && i+z[i] <= lenm) ++z[i];
        if(i + z[i] - 1 > r) l = i , r = i + z[i] - 1; 
    }
}

inline void exkmp(){
    l = r = 0;
    rep(i,1,lens){
        if(i <= r) p[i] = std::min(z[i-l+1],r-i+1);
        while(i + p[i] <= lens && str[i+p[i]] == m[p[i]+1]) ++p[i];
        if(i + p[i] - 1 > r) l = i , r = i + p[i] - 1;
    }
}

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // freopen("in.in", "r", stdin);
    cin >> str+1 >> m+1;
    lens = strlen(str+1) , lenm = strlen(m+1);
    Z();exkmp();
    rep(i,1,lenm) ans ^= (ll)i*(z[i]+1);
    cout << ans << "\n";
    ans = 0;
    rep(i,1,lens) ans ^= (ll)i*(p[i]+1);
    cout << ans << "\n";
    return 0;
}